<?php

/**
 * Holds class Mvc_Controller_Front
 *
 * @author Mark
 *
 * @package Library
 * @subpackage Mvc
 */

/**
 * Determines request routes
 *
 * @author Mark
 */
class Mvc_Controller_Front {

	/**
	 * Dispatcher resource
	 * @var Mvc_Dispatcher $_dispatcher
	 */
	protected $_dispatcher;

	/**
	 * Request resource
	 * @var Mvc_Request $_request
	 */
	protected $_request;

	/**
	 * Router resource
	 * @var Mvc_Router $_router
	 */
	protected $_router;

	/**
	 * Constructor
	 *
	 * @return void
	 */
	public function __construct() {
		$this->_request    = new Mvc_Request();
		$this->_router     = new Mvc_Router($this->_request);
		$this->_dispatcher = new Mvc_Dispatcher($this->_request);
	}

	/**
	 * Runs application
	 *
	 * @return boolean|Mvc_Response
	 */
	public function run() {
		$filename = $this->_router->route();
		return $this->_dispatcher->dispatch($filename);
	}

	/**
	 * Returns dispatcher resource
	 *
	 * @return Mvc_Dispatcher
	 */
	protected function _getDispatcher() {
		return $this->_dispatcher;
	}

	/**
	 * Returns request resource
	 *
	 * @return Mvc_Request
	 */
	protected function _getRequest() {
		return $this->_request;
	}

	/**
	 * Returns router resource
	 *
	 * @return Mvc_Router
	 */
	protected function _getRouter() {
		return $this->_router;
	}

}
